
<!-- ----------------------------------Register form ----------------------------->
		
		<div id="dlg_edit" style="display: none; padding: 5px;"
			title='Đăng ký'>
			<div class="form-container-dialog ui-helper-clearfix  ui-corner-all">
				<form id='registerForm' name='registerForm'>
					<table >
						<tr>
							<td align="left" width="100%">
								<div class="form-panel-auto-dialog">
									<fieldset class="ui-corner-all">
										<table width="100%" id='userRegister' >
											<tr >
												<td align="left" width="150px"><label
													style="float: left; width: 150px" for="email_edit">Email:</label></td>
												<td><input
													style="float: left; "
													type="text"
													name="email_edit" id="email_edit"
													class="text ui-widget-content ui-corner-all"
													maxlength="200" size="25" /> <span
													style="color: red; float: left; width: auto;">*</span></td>
											</tr>
											
											<tr>
												<td align="left" ><label for="password_edit">Mật
														khẩu:</label></td>
												<td align="left" ><input type="password"
													name="password_edit" style=''
													id="password_edit" 
													class="text ui-widget-content ui-corner-all" maxlength="30"
													size="25"  /></td>
											</tr>
											<tr>
												<td align="left" width="120px"><label
													style="float: left; width: 150px"
													for="confirmPassword_edit">Nhập lại mật khẩu:</label></td>
												<td>
												<input style="float: left; " type="password"
													name="confirmPassword_edit" id="confirmPassword_edit"
													class="text ui-widget-content ui-corner-all"
													maxlength="30" size="25" /> 
													<span class='yeucau'>*</span>
												</td>
											</tr>
											<tr>
												<td align="left" ><label for="fullName_edit">Họ
														tên:</label></td>
												<td align="left" ><input
													style="float: left; "
													type="text"
													name="fullName_edit" id="fullName_edit"
													class="text ui-widget-content ui-corner-all"
													maxlength="200" size="25" /> <span class='yeucau'>*</span>
											</tr>
											<tr>
												<td align="left" ><label for="mobil_edit">Điện thoại di động:</label></td>
												<td align="left" ><input
													style="float: left; "
													type="text"
													name="mobil_edit" id="mobil_edit"
													class="text ui-widget-content ui-corner-all"
													maxlength="200" size="25" /> <span class='yeucau'>*</span>
											</tr>
											<tr>
												<td align="left" valign="top"><label for="captcha_edit">Mã xác thực:</label></td>
												<td align="left" valign="top">
												<div class="fl">
													<img   src='<?php echo base_url(); ?>themes/home/images/noCode.jpg' id='captcha' style="border: 1px solid #aaaaaa; width=85px;height:30px; float:left"/>
													<img style="margin-left:10px; cursor:pointer;float:left" alt="Tạo mã khác" title="Tạo mã khác" src="<?php echo base_url(); ?>themes/default/images/refresh.png" onclick="javascript:getCaptCha();" id="reload_button"/>
													<input type="text" size="5" maxlength="5"
													id='captcha_edit' name='captcha_edit'
													style="color: red;float:left;margin-top:7px;margin-left:5px;" class="text ui-widget-content ui-corner-all"/>
												</div>
												</td>
											</tr>
											
										</table>
									</fieldset>
								</div>
							</td>
						</tr>
					</table>
				</form>
			</div>
		</div>
			<!-- ----------------------------------End register form ------------------------------------------------------------------------->
<script type="text/javascript">
/*--------------------Start clear Data---------------------------*/
function clear_Data()
{
	var blank="";
	jQuery('#id_edit').val(blank);
	jQuery('#userName_edit').val(blank);
	jQuery('#fullName_edit').val(blank);
	jQuery('#address_edit').val(blank);
	jQuery('#password_edit').val(blank);
	jQuery('#confirmPassword_edit').val(blank);
	jQuery('#email_edit').val(blank);
	jQuery('#confirmEmail_edit').val(blank);
	jQuery('#birthday_edit').val(blank);
	jQuery('#gender_edit').val(blank);          
	jQuery('#city_edit').val(blank);
	jQuery('#sky_edit').val(blank);
	jQuery('#mobil_edit').val(blank);
	jQuery('#yahoo_edit').val(blank);
	jQuery('#captcha_edit').val(blank);
    jQuery("#chuso").html(blank);
	return true;
}
/*--------------------End clear Data---------------------------*/
/*--------------------Start check Data---------------------------*/
function check_Data()
{
	//checkAdsession();
	 //Check email
	if(!CheckEmail(jQuery("#email_edit").val()))
    {
    	 jQuery("#email_edit").focus();
    	 jQuery.showErr(" Địa chỉ email không hợp lệ!");
    	  addToBasket('bee','email_edit');
    	 return false;
    }
	//Check email is exites
	emailExites('registerForm');
	
    //Check pass:
    if(jQuery("#password_edit").val()=='')
    {
    	 jQuery("#password_edit").focus();
    	 jQuery.showErr(" Xin vui lòng nhập mật khẩu!");
    	 addToBasket('bee','password_edit');
    	 return false;
    }
     //check confirm pass
	if(jQuery('#confirmPassword_edit').val()!=jQuery("#password_edit").val())
	{
		jQuery("#confirmPassword_edit").focus();
     	jQuery.showErr("Xác nhận mật khẩu không giống mật khẩu!");
     	 addToBasket('bee','confirmPassword_edit');
    	return false;
	}
	
	//Check fullName:
    if(jQuery("#fullName_edit").val()=='')
    {
    	 jQuery("#fullName_edit").focus();
    	 jQuery.showErr(" Xin vui lòng nhập Họ và tên!");
    	 addToBasket('bee','fullName_edit');
    	 return false;
    }
	//Check mobil:
    if(jQuery("#mobil_edit").val()=='')
    {
    	 jQuery("#mobil_edit").focus();
    	 jQuery.showErr(" Xin vui lòng nhập số điện thoại di động!");
    	 addToBasket('bee','mobil_edit');
    	 return false;
    }
	  //Check Captcha:
    if(jQuery("#captcha_edit").val()=='')
    {
    	 jQuery("#captcha_edit").focus();
    	 jQuery.showErr(" Xin vui lòng nhập mã xác thực hình trên!");
    	 addToBasket('bee','captcha_edit');
    	 return false;
    }
    
	return true;
}
/*--------------------End check Data---------------------------*/

/*--------------------Start Process Data---------------------------*/

function processData(control)
{
    var openDlg=false;
	//Open dialog:
	jQuery( "#dlg_edit" ).dialog({
		autoOpen: false,
		height: 420,
		width: 460,
		modal: true,
		close: function(ev, ui) 
		{ 		
			
        },
		buttons: {
			Exit: { text:'Hủy bỏ',
				 click:function() {
				 	jQuery( this ).dialog( "close" );	
				}	
			},
			Add:{text:'Đăng ký',
				click:function() {
				 
				   if(!check_Data()) return false;
				   var method={act:'add'};
				   var myJSONtext=jQuery('#registerForm').toJSON();
				   var output = {};
				   output = jsonConcat(output, myJSONtext);
				   output = jsonConcat(output, method);				
					jQuery.ajax
				    ({
				        type: "POST",
				        url: '<?php echo base_url(); ?>user/process',
				        dataType: 'json',
				        async: true,
				        //json object to sent to the authentication url
				        data:output//JSON.stringify(myJSONtext)
				        ,success:function(msg)
				       {	 
				        } 
				    }).done(function( msg ) 
				    {
				    	if(msg.ret=='success')
						{
				    	   alert('Thanh cong');
				    	   jQuery( "#dlg_edit" ).dialog("close" );
				    	   jQuery("#showGrid").clearGridData();
						   jQuery("#showGrid").trigger("reloadGrid");
						}else if(msg.ret=='noCaptcha')
						{
							jQuery("#captcha_edit").focus();
						    jQuery.showErr("Sai thông tin mã xác thực!!");
						    addToBasket('bee','captcha_edit');
							getCaptCha();
						    return false;
						}
						else
						{
							alert('Không thành công!');
						}		
				   });
				}	
		    }
		  }
	});//End open dialog
    
	switch (control)
	{
		case 'display':
			openDlg=fill_Data();
		    break;
		case 'add':
			openDlg=clear_Data();
		    break;
		case 'edit':
			openDlg=fill_Data();
		    break;
		case 'del':
			deleteRecord();
			break;
		default:
	    alert('No process');
	}
	if(openDlg==true)
	{
		jQuery( "#dlg_edit" ).dialog({autoOpen: true});//End open	
    }
}
/*--------------------End Process Data---------------------------*/

</script>